package d10_interface_demo;

import java.util.ArrayList;
import java.util.function.DoubleToIntFunction;

//先搭架构-------->后面在做
public class ClassDataImpl1 implements ClassData {

    //要有一个成员变量接数据
    private ArrayList<Student> students;

    public ClassDataImpl1(ArrayList<Student> students) {
        this.students = students;
    }

    /**
     * 第一套方案
     */
    //展示所有的学生信息
    @Override
    public void printAllStudentInfos() {
        System.out.println("===展示全部学生的信息===");
        //遍历集合
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println(student.getName() + " " + student.getSex() + " " + student.getScore());
        }
    }

    //打印学生平均成绩
    @Override
    public void printAllStudentAverageScore() {
        System.out.println("===展示全部学生的平均分===");
        double sumScore = 0;
        //遍历集合
        for (int i = 0; i < students.size(); i++) {
            double score = students.get(i).getScore();
            sumScore += score;
        }
        //打印平均分
        System.out.println("平均分是:" + (sumScore / students.size()));

    }
}
